﻿namespace PLCComHelperProj
{
    using System;

    public class Tag
    {
        private string address;
        private string dataType;
        private string desc;
        private string m_Name;
        private TagGroup tagGroup_0;

        public Tag(TagGroup tagGroup, string Name, string Address, string DataType, string Desc)
        {
            this.tagGroup_0 = tagGroup;
            this.m_Name = Name;
            this.address = Address;
            this.dataType = DataType;
            this.desc = Desc;
        }

        public e_PLC_DATA_TYPE CheckDataType()
        {
            string dataType = this.dataType;
            if (dataType != null)
            {
                if (dataType == FuckProtect.DataFrom(8))
                {
                    return e_PLC_DATA_TYPE.TYPE_INT;
                }
                if (dataType == FuckProtect.DataFrom(0x12))
                {
                    return e_PLC_DATA_TYPE.TYPE_FLOAT;
                }
                if (dataType == FuckProtect.DataFrom(0x20))
                {
                    return e_PLC_DATA_TYPE.TYPE_BOOL;
                }
                if (dataType == FuckProtect.DataFrom(0x2c))
                {
                    return e_PLC_DATA_TYPE.TYPE_BYTE;
                }
                if (dataType == FuckProtect.DataFrom(0x38))
                {
                    return e_PLC_DATA_TYPE.TYPE_SHORT;
                }
            }
            return e_PLC_DATA_TYPE.TYPE_UNKNOW;
        }

        public string GetAddressName()
        {
            string str = "";
            string dataType = this.dataType;
            if (dataType != null)
            {
                if (dataType != FuckProtect.DataFrom(8))
                {
                    if (dataType != FuckProtect.DataFrom(0x2c))
                    {
                        if (dataType != FuckProtect.DataFrom(0x12))
                        {
                            if (dataType != FuckProtect.DataFrom(0x38))
                            {
                                if (dataType == FuckProtect.DataFrom(0x20))
                                {
                                    str = FuckProtect.DataFrom(0x58);
                                }
                            }
                            else
                            {
                                str = FuckProtect.DataFrom(0x52);
                            }
                        }
                        else
                        {
                            str = FuckProtect.DataFrom(70);
                        }
                    }
                    else
                    {
                        str = FuckProtect.DataFrom(0x4c);
                    }
                }
                else
                {
                    str = FuckProtect.DataFrom(70);
                }
            }
            switch (this.tagGroup_0.Get_MMtype())
            {
                case e_PLC_MMType.MM_DB:
                    return string.Format(FuckProtect.DataFrom(0x5e), new object[] { this.tagGroup_0.MMType, this.tagGroup_0.Block, str, this.address });

                case e_PLC_MMType.MM_UNKNOW:
                    return FuckProtect.DataFrom(130);
            }
            return string.Format(FuckProtect.DataFrom(0x8e), this.tagGroup_0.MMType, str, this.address);
        }

        public string Address
        {
            get
            {
                return this.address;
            }
            set
            {
                this.address = value;
            }
        }

        public string DataType
        {
            get
            {
                return this.dataType;
            }
            set
            {
                this.dataType = value;
            }
        }

        public string Desc
        {
            get
            {
                return this.desc;
            }
            set
            {
                this.desc = value;
            }
        }

        public string Name
        {
            get
            {
                return this.m_Name;
            }
            set
            {
                this.m_Name = value;
            }
        }
    }
}

